home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 1: Comms & Networking / Almathera Ten on Ten - Disc 1: Comms & Networking.iso / tools / archie / archie-1.4 / get_pauth.c < prev    next >
C/C++ Source or Header  |  1995-05-01  |  2KB  |  95 lines

  1. /*
  2.  * Copyright (c) 1989, 1990 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  */
  7. /* Amiga port by Tomas Willis (tomas@cae.wisc.edu) January 1995 */
  8.  
  9. #include <stdio.h>
  10. #ifndef VMS
  11. # include <sys/types.h> /* this may/will define FD_SET etc */
  12. # include "pmachine.h"
  13. #endif
  14.  
  15. #ifdef NEED_STRING_H
  16. # include <string.h>
  17. #else
  18. # include <strings.h>
  19. #endif
  20.  
  21. #ifndef VMS
  22. # if defined(MSDOS) && !defined(OS2) && !defined(PCNFS)
  23. #  ifndef CUTCP
  24. #   include "rwconf.h"
  25. #  endif
  26. # else
  27. #  include "pwd.h"
  28. # endif
  29. #else
  30. # include "jpidef.h"
  31. # include "vms.h"
  32. #endif
  33.  
  34. #include "pcompat.h"
  35. #include "pauthent.h"
  36.  
  37. //protos
  38. PAUTH get_pauth(int type);
  39. //external
  40. unsigned long getuid(void);
  41.  
  42. PAUTH
  43. get_pauth(int type)
  44. //    int        type;
  45.     {
  46.     static PAUTH_ST   no_auth_st;
  47.     static PAUTH          no_auth = NULL;
  48. #if !defined(VMS) && !defined(MSDOS) || defined(OS2) || defined(PCNFS)
  49.     struct passwd *whoiampw;
  50. #else
  51.     char username[13];
  52.     unsigned short usernamelen;
  53.     struct {
  54.         unsigned short buflen;
  55.         unsigned short itmcod;
  56.         char *bufadr;
  57.         unsigned short *retlenadr;
  58.         unsigned long null;
  59.     } jpi_itemlist;
  60. #endif
  61.  
  62.     if(no_auth == NULL) {
  63.         no_auth = &no_auth_st;
  64.         strcpy(no_auth->auth_type,"UNAUTHENTICATED");
  65.  
  66.         /* find out who we are */
  67. #ifndef VMS
  68. #if (defined(MSDOS) ) && !defined(OS2) && !defined(PCNFS)
  69. #ifndef CUTCP
  70.         if (!getconf("general", "user", no_auth->authenticator, 250)
  71.         || (strlen (no_auth->authenticator) == 0))
  72. #endif
  73.           strcpy(no_auth->authenticator,"nobody");
  74. #else /* not MSDOS */
  75.         DISABLE_PFS(whoiampw = getpwuid(getuid()));
  76.         if (whoiampw == 0) strcpy(no_auth->authenticator,"nobody");
  77.         else strcpy(no_auth->authenticator, whoiampw->pw_name);
  78. #endif /* not MSDOS */
  79. #else
  80.         jpi_itemlist.buflen = sizeof(username);
  81.         jpi_itemlist.itmcod = JPI$_USERNAME;
  82.         jpi_itemlist.bufadr = &username;
  83.         jpi_itemlist.retlenadr = &usernamelen;
  84.         jpi_itemlist.null = 0;
  85.         if (SYS$GETJPI(0, 0, 0, &jpi_itemlist, 0, 0, 0) & 0x1)
  86.         {
  87.         username[usernamelen] = 0;
  88.         strcpy(no_auth->authenticator, username);
  89.         } else
  90.         strcpy(no_auth->authenticator, "nobody");
  91. #endif
  92.     }
  93.     return(no_auth);
  94.     }
  95.